<%@page contentType="text/html;charset=utf-8" 
 import="java.util.Properties, git.bankview.sl.schedule.PipelineFactory
 , java.util.Date, java.util.Calendar, java.util.Enumeration" 
%><%@ include file="/jsp/inc/pageUtils.jsp"
%><%
	response.addHeader("Cache-Control", "no-cache");
	String taskids = request.getParameter("taskids");
	String[] vTaskId = taskids.split(",");
	Properties userParams = new Properties();
	Enumeration en = request.getParameterNames();
	while(en.hasMoreElements())
	{
		String pname = (String)en.nextElement();
		userParams.setProperty(pname, request.getParameter(pname));
	}
	//userParams.putAll(request.getParameterMap());
	//Calendar cale = Calendar.getInstance();
	//cale.set(Calendar.YEAR, 1999);	// 1999
	//cale.set(Calendar.MONTH, 1 - (1));	// 1
	//cale.set(Calendar.DATE, 1);	//1
	java.sql.Date taskDate = new java.sql.Date(new java.util.Date().getTime());
	System.out.println("开始执行巨灾数据处理任务(by " + request.getRemoteAddr() + "): " + taskids + "; Schedule: " + taskDate);
%>
<html>
<head>
<style>
body { background-color: #dbe4f3; margin: 0px; }
div { width: 160px; height: 60px; font-size: 10pt; }
.msg { color: #565f70; }
.warn { color: #eb403e; }
</style>
</head>
<body>
	<div id="oResult" class="msg">执行最后的数据处理, <br>请稍候...</div>
	<input style="display: none; " type="button" id="oReloadButton" onclick="parent.location.reload();" value="点击这里完成">
</body>
</html>
<%
	out.flush();
	String result = null;
	String taskid = null;
	
	try
	{
		for (int i = 0; i < vTaskId.length; ++i)
		{
			taskid = vTaskId[i];
			System.out.println("开始执行任务: [" + taskid + "]");
			System.out.println("任务属性: " + userParams);
			result = PipelineFactory.runTaskById(Integer.parseInt(taskid), taskDate, userParams);
			%><script>
			/**** 
			<%= result%>
			*/
			System.out.println(taskid + "任务执行结果: " + result);
			oResult.innerText += "...";
			</script><%
			out.flush();
		}
		%>
		<script>oResult.innerText = "数据处理完成"; </script>
		<%
	}
	catch(Exception e)
	{
		System.out.println("巨灾数据处理任务执行失败, 原因: " + e.getMessage());
		e.printStackTrace();
		%><script>oResult.innerText = "数据处理失败(<%=taskid%>)";
		oResult.innerText += "<% if (null != e.getMessage()) { %>\n原因: <%=e.getMessage().trim()%><% } %>"; 
		</script><%
		out.flush();
	}
%>
<script>
oReloadButton.style.display = "";
</script>

